﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>购物车</title>
    @V5.Html.Partial("User/_ChkUser")
    <meta name="Keywords" content="网络购物，网上超市，网上购物，购物，网上商店，购物商城,购物网，超市网,世博会门票购买" />
    <meta name="Description" content="用鼠标逛超市，不用排队，方便实惠送上门，网上购物新生活。" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--css start-->
    <link type="text/css" rel="stylesheet" href="/@V5.Config.TemplatePath/css/base.css"/>
    <link type="text/css" rel="stylesheet" href="/@V5.Config.TemplatePath/css/product_detail.css"/>
    <!--css end-->
    <script src="/@V5.Config.TemplatePath/javascript/jquery.min.js" type="text/javascript"></script>
    <script src="/@V5.Config.TemplatePath/javascript/Comon.js" type="text/javascript" charset="UTF-8"></script>
    <script src="/@V5.Config.TemplatePath/javascript/loading/loading_source.js" type="text/javascript" charset="UTF-8"></script> 
    <link href="/@V5.Config.TemplatePath/javascript/dialog/css/custom-theme/dialog.css" rel="stylesheet" type="text/css"/>
    <script src="/@V5.Config.TemplatePath/javascript/dialog/js/jquery-ui-dialog.min.js" type="text/javascript"></script>

    @V5.Html.Partial("includes/tView")
    @{
        var ItemList = (List<V5_Model.BuyerItem>)Session["BuyerItemList"];
        V5_EShop._Class.Model.ModelGZProduct Model = new V5_EShop._Class.Model.ModelGZProduct();
        decimal totalPrice = 0;
        decimal listScore = 0;
        var user = (V5_Model.ModelGZUser)Session["isLogin"];  
    }
</head>
<body>
    <!--主要导航区 -->
    @V5.Html.Partial("includes/header")
    <!--content start-->
    <div class="wrap">
        <!--购物车 -->
        <div class="gray-box pro-li mt10">
            <div class="clearfix shop_name">
                <h2>
                    <input type="checkbox" id="allselect_top" class="ipc allselect"><label for="allselect_top">全选</label>
                </h2>
                @* <div class="fr textSlider">
        <ul>
          <li><a title="查看运费详情" target="_blank" href="/deliveryinfo/deliveryInfo.do"> 1号店商家每满<span class="red">100元</span>免<span class="red">10kg</span>运费,服装类商品满<span class="red">100元</span>免<span class="red">1kg</span>运费</a></li>
        </ul>
      </div>*@
            </div>
            
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="clear list">
                <tbody>
                    <tr class="">
                        <th width="25">
                        </th>
                        <th width="70">
                        </th>
                        <th width="310">
                            商品名称
                        </th>
                        <th width="80">
                            价格
                        </th>
                        <th width="80">
                            数 量
                        </th>
                        <th width="172">
                            商品合计
                        </th>
                        <th width="70">
                            操 作
                        </th>
                    </tr>
                    @if (ItemList != null && ItemList.Count > 0)
                    {
                        foreach (var item in ItemList)
                        {

                            Model = new V5_EShop._Class.BLL.BLLGZProduct().GetModel(System.Guid.Parse(item.ID.ToUpper()));

                            decimal prices = new V5_EShop._Class.BLL.BLLGZProduct().GetPrice(user, Model); 

                            totalPrice += prices * item.Amount;
                            listScore += Model.GiftsIntegral.Value;
                            
                            <tr class="detail_item_tr" id="detail_@(item.gid)">
                                <td class="first_td">
                                    <input type="checkbox" value="@item.gid" id="Chk_Item_@(item.gid)" class="item_chk"/>
                                </td>
                                <td>
                                    <a target="_blank"  href="http://www.yihaodian.com/product/1703147_3"
                                        class="smalimg">
                                        <img src="@Model.PicturePath" style="width:60px;height:60px;"/></a>
                                </td>
                                <td class="tl">
                                    <h3>
                                        <a target="_blank"  href="@V5.Url.Action("Product/View", new { ID = item.ID.ToString() })">@Model.ProductName</a>
                                    </h3>
                                </td>
                                <td>
                                     <strong class="red">￥@prices</strong>
                                </td>
                                <td>
                                     @item.Amount
                                </td>
                                <td>
                                    <span id="total_items_1703147_0"><strong class="red">￥@(prices * item.Amount)</strong> </span>
                                    @Html.Hidden("Item_Price_" + Model.ID, prices * item.Amount, new { @class = "Item_Price" })
                                </td>
                                <td class="last_td">
                                    <span><a data-id="@item.gid"  class="deleteButton" href="javascript:void(0);">删除</a> </span>
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                         <tr class="detail_item_tr" id="detail_@Model.ID">
                                <td class="first_td" colspan="7">
                                   暂无商品
                                </td>
                                
                         </tr> 
                    }
                </tbody>
            </table>
          
            <p class="subtotal" style="height:90px" >  
                <span style="float:left">备注：</span>
                <textarea style="width:550px;height:100px;float:left" id="txt_remarke"></textarea>
                 <a href='javascript:;' class="ActiveCenterBg" style="float:left;margin-top:70px;margin-left:10px" id="btn_AddNews">活动中心</a>
            </p>
        </div>
        <div class="fix_btm_bar clearfix" style="width: 100%">
             
            <div class="fr"> 
                <strong>商品总价： <span id="total_price_bottom" class="red" data-price="@totalPrice">@totalPrice </span>元 </strong>
                <button onclick="window.location.href='/index.aspx'" class="ctn_shopping" id="nextstep">
                    继续购物</button>
                <button class="settlement " id="confirmToPay">提交订单</button>
            </div>
             @if (listScore > 0)
             {
                <div class="fr" style="margin-right:20px">   
                <strong>本单兑换积分：<span class="red">@listScore.ToString("0") </span>  你的积分：<span class="red">@user.ExistingIntegral.Value.ToString("0") </span>分</strong> 
                 <input id="user_score" type="checkbox" style="margin: 0px 3px 0px 10px;"/>积分兑换
                 @Html.Hidden("g_totalScore", listScore)
                 @Html.Hidden("g_userScore", user.ExistingIntegral)

                 <script>
                     $("#user_score").attr("checked", false);
                     $("#user_score").bind("click", function () {
                         if (parseFloat($("#g_totalScore").val()) <= parseFloat($("#g_userScore").val())) {
                             var pp = $("#total_price_bottom").attr("data-price");
                             if ($(this).is(":checked")) {
                                 $("#total_price_bottom").html("<del>" + pp + "</del>");
                             }
                             else {
                                 $("#total_price_bottom").html(pp);
                             }
                         }
                         else {
                             $(this).attr("checked", false);
                             msg("你的积分不足！");
                         }

                     });
                 </script>
                </div>
             }
            <script>

                $("#confirmToPay").bind("click", function () {
                    var url = '/SubmitBuyerList.aspx';
                    var obj = $("#user_score");
                    var txtRemark = $("#txt_remarke");
                    var para = "c=" + txtRemark.val();

                    if (obj.attr("id") != undefined && obj.attr("checked")) {
                        para += "&u=1";
                    }

                    showLoading();
                    $.ajax({
                        type: "Post",
                        url: url,
                        data: para,
                        success: function (result) {

                            if (result.indexOf("请先登录") > -1) {
                                msg("请先登录！");
                            }
                            else if (result.indexOf("请先购物") > -1) {
                                msg("请先购物！");
                            }
                            else {
                                msg("添加成功！");
                                showLoading();
                                window.location.href = '/index.aspx?t=user/MyBill';
                            }
                        },
                        complete: function () {
                            hideLoading();
                        }
                    });

                });

             
            
            </script>
            <div class="selectbox_btm">
                <input type="checkbox" id="allselect_bottom" class="ipc allselect"/><label for="allselect_bottom">全选</label>
                <a class="ablue"  href="javascript:void(0);" id="Item_BatchClear">批量删除</a> 
                <a class="ablue" href="javascript:void(0);" id="Item_ClearAll">清空购物车</a>
            </div>
        </div>
        @*<div id="ajaxViewAndBuy">
    <div class="also_buy also_product_list">
      <div class="title">
        <h2>看过本商品的用户还购买过</h2>
      </div>
      <div class="also_buy_box" style="width:96%">
        <div class="slide_box">
          <ul style="width: 1350px;">
            <li style="overflow:hidden;_zoom:1"><a href="" title="" class="pic" ><img src="images/1356301_115x115.jpg" height="115" width="115"></a>
              <div class="info">
                <h3><a href="" title="" ><strong>40%会买：</strong>AJI 尼西亚金黄乳酪味（起士）惊奇脆饼干200g/袋</a></h3>
                <p class="price"><strong>￥7.9</strong><del>￥21.9</del></p>
                <p class="btn"><a href="javascript:void(0)" onclick='gotracker("2","1mahoutBtn_0","1065870");addToCart(event,"1065870","3","1");'>
                  <input value="加入购物车" type="button">
                  </a></p>
              </div>
            </li>
            <li style="overflow:hidden;_zoom:1"><a href="" title="" class="pic" ><img src="images/1356301_115x115.jpg" height="115" width="115"></a>
              <div class="info">
                <h3><a href="" title="" ><strong>40%会买：</strong>AJI 尼西亚金黄乳酪味（起士）惊奇脆饼干200g/袋</a></h3>
                <p class="price"><strong>￥7.9</strong><del>￥21.9</del></p>
                <p class="btn"><a href="javascript:void(0)" onclick='gotracker("2","1mahoutBtn_0","1065870");addToCart(event,"1065870","3","1");'>
                  <input value="加入购物车" type="button">
                  </a></p>
              </div>
            </li>
            <li style="overflow:hidden;_zoom:1"><a href="" title="" class="pic" ><img src="images/1356301_115x115.jpg" height="115" width="115"></a>
              <div class="info">
                <h3><a href="" title="" ><strong>40%会买：</strong>AJI 尼西亚金黄乳酪味（起士）惊奇脆饼干200g/袋</a></h3>
                <p class="price"><strong>￥7.9</strong><del>￥21.9</del></p>
                <p class="btn"><a href="javascript:void(0)" onclick='gotracker("2","1mahoutBtn_0","1065870");addToCart(event,"1065870","3","1");'>
                  <input value="加入购物车" type="button">
                  </a></p>
              </div>
            </li>
            <li style="overflow:hidden;_zoom:1"><a href="" title="" class="pic" ><img src="images/1356301_115x115.jpg" height="115" width="115"></a>
              <div class="info">
                <h3><a href="" title="" ><strong>40%会买：</strong>AJI 尼西亚金黄乳酪味（起士）惊奇脆饼干200g/袋</a></h3>
                <p class="price"><strong>￥7.9</strong><del>￥21.9</del></p>
                <p class="btn"><a href="javascript:void(0)" onclick='gotracker("2","1mahoutBtn_0","1065870");addToCart(event,"1065870","3","1");'>
                  <input value="加入购物车" type="button">
                  </a></p>
              </div>
            </li>
            <li style="overflow:hidden;_zoom:1"><a href="" title="" class="pic" ><img src="images/1356301_115x115.jpg" height="115" width="115"></a>
              <div class="info">
                <h3><a href="" title="" ><strong>40%会买：</strong>AJI 尼西亚金黄乳酪味（起士）惊奇脆饼干200g/袋</a></h3>
                <p class="price"><strong>￥7.9</strong><del>￥21.9</del></p>
                <p class="btn"><a href="javascript:void(0)" onclick='gotracker("2","1mahoutBtn_0","1065870");addToCart(event,"1065870","3","1");'>
                  <input value="加入购物车" type="button">
                  </a></p>
              </div>
            </li>
            <li style="overflow:hidden;_zoom:1"><a href="" title="" class="pic" ><img src="images/1356301_115x115.jpg" height="115" width="115"></a>
              <div class="info">
                <h3><a href="" title="" ><strong>40%会买：</strong>AJI 尼西亚金黄乳酪味（起士）惊奇脆饼干200g/袋</a></h3>
                <p class="price"><strong>￥7.9</strong><del>￥21.9</del></p>
                <p class="btn"><a href="javascript:void(0)" onclick='gotracker("2","1mahoutBtn_0","1065870");addToCart(event,"1065870","3","1");'>
                  <input value="加入购物车" type="button">
                  </a></p>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>*@
    </div>
    <!--消费资讯-->
    @V5.Html.Partial("includes/Footer")
     <div id="NewsDialog" style="display:none;">  
        <div id="NewsLoading">加载中...</div>
        <div id="NewsInfo" style="display:none; "></div>
    </div>
</body>
</html>



<script>
    $(function () {
        $(".allselect").bind("click", function () {
            if ($(this).is(":checked")) {
                $(".item_chk").attr("checked", true);
                $(".allselect").attr("checked", true);
            }
            else {
                $(".item_chk").attr("checked", false);
                $(".allselect").attr("checked", false);
            }
        });

        $("#btn_AddNews").bind("click", function () {
            NewsAction();
        });

        $(".news_item_flow_select").live("click", function () {
            $("#txt_remarke").val($(this).attr("data-title"));
            $("#NewsDialog").dialog('close');
        });


        var clearNewsInfo = function () {
            $("#NewsLoading").show();
            $("#NewsInfo").html("").hide();
        }

        var NewsAction = function () {
            $('#NewsDialog').dialog({
                modal: true,
                autoOpen: true,
                width: 800,
                height: 400,
                title: '添加备注',
                open: function () {
                    clearNewsInfo();
                    $.ajax({
                        type: "Post",
                        url: "/index.aspx?t=GetNews",
                        success: function (result) {
                            $("#NewsLoading").hide();
                            $("#NewsInfo").html(result).show();
                        },
                        complete: function () {
                            hideLoading();
                        }
                    });
                },
                close: function () {
                    clearNewsInfo();
                }
            });
        }


        $(".deleteButton").bind("click", function () {
            if (confirm("确认删除？")) {
                clearItem($(this).attr('data-id'));
            }
        });

        $("#Item_BatchClear").bind("click", function () {
            if (confirm("确认删除？")) { 
                if ($(".item_chk:checked").length > 0) {
                    var s = "";
                    $(".item_chk:checked").each(function () {
                        s += $(this).val() + "|";
                    });
                    clearItem(s);
                }
                else {
                    msg("请先选择");
                }
            }
        });

        $("#Item_ClearAll").bind("click", function () {
            if (confirm("确认删除？")) { 
                if ($(".item_chk").length > 0) { 
                    clearItem("-1");
                }
                else {
                    msg("没有商品可删！");
                }
            } 
        });
    });


    var clearItem = function (id) {
        $.ajax({
            type: "POST",
            url: "/ClearItem.aspx",
            data: "ID=" + id,
            success: function (res) {
                if (res == "0") {
                    if (id == "-1") {
                        $(".detail_item_tr").remove();
                    }
                    else {
                        var tids = id.split('|');
                        for (var i = 0; i < tids.length; i++) {
                            if (tids[i] != "")
                                DelItem(tids[i]);
                        }
                    }
                    msg("删除成功！");
                }
                else {
                    msg(res);
                }
            }
        });
    }

    var DelItem = function (id) { 
        $("#detail_" + id).fadeOut().remove();
        var total=0;
        $(".Item_Price").each(function () {
            total += parseFloat($(this).val());
        });
        $("#total_price_bottom").html(total);
    }

</script>